# Copyright (c) 2025 Huawei Technologies Co., Ltd.
# This file is a part of the CANN Open Software.
# Licensed under CANN Open Software License Agreement Version 1.0 (the "License").
# Please refer to the License for details. You may not use this file except in compliance with the License.
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
# See LICENSE in the root of the software repository for the full text of the License.
# ======================================================================================================================

    add_executable(matmul_all_reduce
            test_matmul_all_reduce.cpp
    )
    add_execute_example(
            TARGET_NAME matmul_all_reduce
            SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/run_matmul_all_reduce_case.sh
            TEST_CASE matmul_all_reduce
            ACLNN_FUNC "aclnnMatmulAllReduce"
    )

    add_executable(matmul_all_reduce_v2
            test_matmul_all_reduce_v2.cpp
    )
    add_execute_example(
            TARGET_NAME matmul_all_reduce_v2
            SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/run_matmul_all_reduce_case.sh
            TEST_CASE matmul_all_reduce_v2
            ACLNN_FUNC "aclnnMatmulAllReduceV2"
    )

    add_executable(quant_matmul_all_reduce
            test_quant_matmul_all_reduce.cpp
    )
    add_execute_example(
            TARGET_NAME quant_matmul_all_reduce
            SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/run_matmul_all_reduce_case.sh
            TEST_CASE quant_matmul_all_reduce
            ACLNN_FUNC "aclnnQuantMatmulAllReduce"
    )

    add_executable(quant_matmul_all_reduce_v2
            test_quant_matmul_all_reduce_v2.cpp
    )
    add_execute_example(
            TARGET_NAME quant_matmul_all_reduce_v2
            SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/run_matmul_all_reduce_case.sh
            TEST_CASE quant_matmul_all_reduce_v2
            ACLNN_FUNC "aclnnQuantMatmulAllReduceV2"
    )

    add_executable(quant_matmul_all_reduce_v3
            test_quant_matmul_all_reduce_v3.cpp
    )
    add_execute_example(
            TARGET_NAME quant_matmul_all_reduce_v3
            SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/run_matmul_all_reduce_case.sh
            TEST_CASE quant_matmul_all_reduce_v3
            ACLNN_FUNC "aclnnQuantMatmulAllReduceV3"
    )

    add_executable(weight_quant_matmul_all_reduce
            test_weight_quant_matmul_all_reduce.cpp
    )
    add_execute_example(
            TARGET_NAME weight_quant_matmul_all_reduce
            SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/run_matmul_all_reduce_case.sh
            TEST_CASE weight_quant_matmul_all_reduce
            ACLNN_FUNC "aclnnWeightQuantMatmulAllReduce"
    )

    install(TARGETS matmul_all_reduce matmul_all_reduce_v2 quant_matmul_all_reduce quant_matmul_all_reduce_v2 quant_matmul_all_reduce_v3 weight_quant_matmul_all_reduce
            LIBRARY DESTINATION lib
            ARCHIVE DESTINATION lib
            RUNTIME DESTINATION bin
            OPTIONAL
    )
    target_link_libraries(matmul_all_reduce PRIVATE
        -lc_sec
        -lhccl
    )
    target_link_libraries(matmul_all_reduce_v2 PRIVATE
        -lc_sec
        -lhccl
    )
    target_link_libraries(quant_matmul_all_reduce PRIVATE
        -lc_sec
        -lhccl
    )
    target_link_libraries(quant_matmul_all_reduce_v2 PRIVATE
        -lc_sec
        -lhccl
    )
    target_link_libraries(quant_matmul_all_reduce_v3 PRIVATE
        -lc_sec
        -lhccl
    )
    target_link_libraries(weight_quant_matmul_all_reduce PRIVATE
        -lc_sec
        -lhccl
    )